//
//  SubmitUserAuthInfoViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/25.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "SubmitUserAuthInfoViewController.h"
#import "HttpRequest.h"
#import "AddressView.h"
@interface SubmitUserAuthInfoViewController  ()<UITextFieldDelegate,UIGestureRecognizerDelegate ,UIScrollViewDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate>
@property(nonatomic,retain)NSString* st;
@property(nonatomic,retain)NSString*code;
@end

@implementation SubmitUserAuthInfoViewController

{   UIScrollView*mainScroll;
    UIScrollView*mainScroll1;
    UITextField* userNameTextField;
    UITextField* PasswordTextField;
    UITextField* phoneTextField;
    UITextField* payPasswordTextField;
    UITextField* VerificationCode;
    UIButton* ToObtain;
    BOOL saveAccount;
    UIView* view1;
    UIView* view2;
    UIButton* agreementBtn;
    MBProgressHUD *progressHud;
    UIView*myToolBar;
    UIButton* registdd;
    UIButton*jiadaagreementBtn;
    UIButton*GPRSAddress;
    NSMutableArray* arrrss;
    AddressView*Addressview;
    UILabel* GPRS;
}
@synthesize alt = alt;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)BackAction:(UIButton *)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"身份认证";
// 手势
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [self.view addGestureRecognizer:singleFingerOne];
    mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight)];
    
    [mainScroll setBackgroundColor:[UIColor colorWithRed:255/255.00 green:255/255.00 blue:255/255.00 alpha:1.0]];
    mainScroll.delegate = self;
    mainScroll.userInteractionEnabled = YES;
    mainScroll.scrollEnabled = YES;
    
    
    
    UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
    view.backgroundColor=zuiqianhuiColor;
    [mainScroll addSubview:view];
    GPRS=[[UILabel alloc]initWithFrame:CGRectMake(15, 25/2, 140, 15)];
    GPRS.text=[NSString stringWithFormat:@"请选择身份"];
    GPRS.textColor=zhonghuiColor;
    GPRS.font=[UIFont systemFontOfSize:contenfot];
    [mainScroll addSubview:GPRS];
    GPRSAddress=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/2-20,  25/2,ScreenWidth/2-20,15)];
    [GPRSAddress setTitle:nil forState:UIControlStateNormal];
    GPRSAddress.titleLabel.font=[UIFont systemFontOfSize:contenfot];
    GPRSAddress.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [GPRSAddress addTarget:self action:@selector(GPRSAddress:) forControlEvents:UIControlEventTouchUpInside];
    [GPRSAddress setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [mainScroll addSubview:GPRSAddress];
    UIButton*jiantouBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-30,30/2,46/3, 25/3)];
    [jiantouBtn setImage:[UIImage imageNamed:@"xiangxia-"] forState:UIControlStateNormal];
    [jiantouBtn addTarget:self action:@selector(GPRSAddress:) forControlEvents:UIControlEventTouchUpInside];
    [mainScroll addSubview:jiantouBtn];
    UILabel *line0 = [[UILabel alloc]initWithFrame:CGRectMake(10,190/2, ScreenWidth-20, 0.45)];
    line0.backgroundColor = qianhuiColor;
    [mainScroll addSubview:line0];
    UILabel *line1 = [[UILabel alloc]initWithFrame:CGRectMake(10,280/2, ScreenWidth-30, 0.45)];
    line1.backgroundColor = qianhuiColor;
    [mainScroll addSubview:line1];
    UILabel *line2 = [[UILabel alloc]initWithFrame:CGRectMake(10,370/2, ScreenWidth-20, 0.45)];
    line2.backgroundColor = qianhuiColor;
    [mainScroll addSubview:line2];
    
    userNameTextField = [[UITextField alloc] initWithFrame:CGRectMake(15,  100/2, ScreenWidth-35, 45)];
    [userNameTextField setBorderStyle:   UITextBorderStyleNone]; //外框类型
    userNameTextField.placeholder = @"请输入姓名"; //默认显示的字
    userNameTextField.font = [UIFont systemFontOfSize: 16.0];
    userNameTextField.returnKeyType = UIReturnKeyDone;
    userNameTextField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
    userNameTextField.delegate = self;
//    userNameTextField.keyboardType = UIKeyboardTypeDecimalPad;
    [userNameTextField addTarget:self action:@selector(userNumberLimitTextLength:) forControlEvents:UIControlEventEditingChanged];
    [mainScroll addSubview:userNameTextField];
    
    phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(15,  190/2, ScreenWidth-35, 45)];
    [phoneTextField setBorderStyle:   UITextBorderStyleNone]; //外框类型
    phoneTextField.placeholder = @"请输入手机号码"; //默认显示的字
    phoneTextField.font = [UIFont systemFontOfSize: 16.0];
    phoneTextField.returnKeyType = UIReturnKeyDone;
    phoneTextField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
    phoneTextField.delegate = self;
    phoneTextField.keyboardType = UIKeyboardTypeDecimalPad;
    [phoneTextField addTarget:self action:@selector(userNumberLimitTextLength:) forControlEvents:UIControlEventEditingChanged];
    [mainScroll addSubview:phoneTextField];
    
    myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
    myToolBar.backgroundColor=jianpancolor;
    UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
    [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:tubtnDone];
    UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
    [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
    [btnDone111 setTitleColor:luseColor forState:UIControlStateNormal];
    btnDone111 .titleLabel .font=[UIFont systemFontOfSize:keyboardFot];
    [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:btnDone111];
    myToolBar.alpha=alp;
    
    UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
    [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:dabtn];
    
    phoneTextField.inputAccessoryView = myToolBar;
    
userNameTextField.inputAccessoryView = myToolBar;
    VerificationCode = [[UITextField alloc] initWithFrame:CGRectMake(15, 280/2, 190, 45)];
    [VerificationCode setBorderStyle:UITextBorderStyleNone]; //外框类型
    VerificationCode.placeholder = @"请输入手机验证码"; //默认显示的
    VerificationCode.font = [UIFont systemFontOfSize: 16.0];
    VerificationCode.autocorrectionType = UITextAutocorrectionTypeNo;
    VerificationCode.autocapitalizationType = UITextAutocapitalizationTypeNone;
    VerificationCode.returnKeyType = UIReturnKeyDone;
//  VerificationCode.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
    VerificationCode.delegate = self;
    VerificationCode.tag=2;
    VerificationCode.keyboardType = UIKeyboardTypeDecimalPad;
    [mainScroll addSubview:VerificationCode];
    VerificationCode.inputAccessoryView = myToolBar;
    ToObtain = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth*930/1240, 300/2, ScreenWidth*245/1240,26)];
    [ToObtain setTitle:@"获取验证码" forState:UIControlStateNormal];
    ToObtain.titleLabel.font = [UIFont systemFontOfSize: 13.0];
    [ToObtain.layer setCornerRadius:3.0]; //设置矩圆角半径
    [ToObtain.layer setBorderWidth:0.5];   //边框宽度
    CGColorSpaceRef tureBTnSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef tureBTncolorref = CGColorCreate(tureBTnSpace,(CGFloat[]){228/255.0, 228/255.0, 228/255.0, 1.0});
    [ToObtain.layer setBorderColor:tureBTncolorref];//边框颜色
    [ToObtain setTitleColor:[UIColor colorWithRed:249/255.0 green:53/255.0 blue:30/255.0 alpha:1.0]
                   forState:UIControlStateNormal];
    [ToObtain addTarget:self action:@selector(startTime) forControlEvents:UIControlEventTouchUpInside];
    [mainScroll addSubview:ToObtain];
    
    registdd = [[UIButton alloc] initWithFrame:CGRectMake(15, 540/2, ScreenWidth-30, anniuHeigth)];
    [registdd setTitle:@"立即认证" forState:UIControlStateNormal];
    [registdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registdd.layer setCornerRadius:2.0]; //设置矩圆角半径
    [registdd.layer setBorderWidth:0.3];   //边框宽度
    CGColorSpaceRef tureBTnSpace44 = CGColorSpaceCreateDeviceRGB();
    CGColorRef tureBTncolorref44 = CGColorCreate(tureBTnSpace44,(CGFloat[]){204.0/255.0, 204.0/255.0, 204.0/255.0, 1.0});
    [registdd.layer setBorderColor:tureBTncolorref44];//边框颜色
    registdd.backgroundColor=qianhuiColor;
    [mainScroll addSubview:registdd];
    
    [mainScroll setContentSize:CGSizeMake(ScreenWidth, ScreenHeight+50)];
    [self.view addSubview:mainScroll];
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    NSMutableDictionary *param = [NSMutableDictionary new];
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    [param setValue:Token forKey:@"tokenId"];
    
 


    [HttpRequest requestData:@"System/AppCode/UserType" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
               
                arrrss=[[NSMutableArray alloc]init];
                
                arrrss=[severDataDict.dataDict objectForKey:@"DataLine"];
                
               
                [GPRSAddress setTitle:[[arrrss objectAtIndex:0]objectForKey:@"content"] forState:UIControlStateNormal];
                self.code=[[arrrss objectAtIndex:0]objectForKey:@"code"];
                
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
           
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
        
    }];
    
}


-(void)GPRSAddress:(UIButton*)sender{
    
    
    
    mainScroll1 = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64+view1.bottom, ScreenWidth, ScreenHeight/2)];
    mainScroll1.delegate = self;
    mainScroll1.userInteractionEnabled = YES;
    mainScroll1.scrollEnabled = YES;
    mainScroll1.backgroundColor=[UIColor whiteColor];
    mainScroll1.alpha=0.99;
    [self.view addSubview:mainScroll1];
    
    if (arrrss.count>0) {
        
        for (int i = 0; i<arrrss.count; i++) {
            
            Addressview = [[AddressView alloc]initWithFrame:CGRectMake(0, 0+(50*i), ScreenWidth, 50)];
            
            Addressview.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
            Addressview.buttonView.titleLabel.font=[UIFont systemFontOfSize:contenfot];
            
            [Addressview.buttonView setTitle: [[arrrss objectAtIndex:i] objectForKey:@"content"] forState:UIControlStateNormal];
            Addressview.buttonView.backgroundColor=[UIColor whiteColor];
            Addressview.buttonView.tag=i;
            [Addressview.buttonView setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
            [Addressview.buttonView setTitleColor:shenhuiColor forState:0];
            [Addressview.buttonView addTarget:self action:@selector(xuanzhi:) forControlEvents:UIControlEventTouchUpInside];
            
            [mainScroll1 addSubview:Addressview];
        }
        
        
        [mainScroll1 setContentSize:CGSizeMake(ScreenWidth, Addressview.bottom)];
    }
    
    
}
-(void)xuanzhi:(UIButton *)sender {
    self.code=[[arrrss objectAtIndex:sender.tag]objectForKey:@"code"];
    NSLog(@"%@",self.code);
    [mainScroll1 removeFromSuperview];
    
    [GPRSAddress setTitle:sender.titleLabel.text forState:UIControlStateNormal];
    
    
}

-(void)registdd:(UIButton*)sender{
    
    if ([phoneTextField.text length]<1)
    {
        [self showAlertMessage:@"请输入手机号码"];
        
    }else if ([VerificationCode.text length]<1)
    {
        [self showAlertMessage:@"请输入验证码"];
    }
    
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
    NSLog(@"end");
    
    
    
    if (textField.tag==2){
        if (textField.text.length == 0) {
            registdd = [[UIButton alloc] initWithFrame:CGRectMake(15, 540/2, ScreenWidth-30, anniuHeigth)];
            [registdd setTitle:@"立即认证" forState:UIControlStateNormal];
            [registdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [registdd.layer setCornerRadius:2.0]; //设置矩圆角半径
            [registdd.layer setBorderWidth:0.3];   //边框宽度
            CGColorSpaceRef tureBTnSpace44 = CGColorSpaceCreateDeviceRGB();
            CGColorRef tureBTncolorref44 = CGColorCreate(tureBTnSpace44,(CGFloat[]){204.0/255.0, 204.0/255.0, 204.0/255.0, 1.0});
            [registdd.layer setBorderColor:tureBTncolorref44];//边框颜色
            registdd.backgroundColor=qianhuiColor;
            [mainScroll addSubview:registdd];
            
            
        }
        
        if (textField.text.length>1) {
            [registdd removeFromSuperview];
            registdd = [[UIButton alloc] initWithFrame:CGRectMake(15,540/2, ScreenWidth-30, anniuHeigth)];
            [registdd setTitle:@"立即认证" forState:UIControlStateNormal];
            [registdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            registdd.backgroundColor=luseColor;
            [registdd.layer setCornerRadius:3.0]; //设置矩圆角半径
            [registdd.layer setBorderWidth:0.3];   //边框宽度
            CGColorSpaceRef tureBTnSpace = CGColorSpaceCreateDeviceRGB();
            CGColorRef tureBTncolorref = CGColorCreate(tureBTnSpace,(CGFloat[]){23/255.0,148/255.0, 153/255.0, 1.0});
            [registdd.layer setBorderColor:tureBTncolorref];//边框颜色
            [registdd addTarget:self action:@selector(regist:) forControlEvents:UIControlEventTouchUpInside];
            [mainScroll addSubview:registdd];
            
            
        }
    }

    
    
    
    return YES;
}



//号码限制
- (void)userNumberLimitTextLength:(UITextField*)textField
{
    
    
    if ([textField.text length] >= 11)
    {
        textField.text = [textField.text substringToIndex:11];
        
        
        
        
    }
}
- (void)payPasswordTextField:(UITextField*)textField
{
    if ([textField.text length] > 20)
    {
        //        NSRange range=NSMakeRange(6,20);
        //        textField.text = [textField.text substringFromIndex:];
    }
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    
    if (textField.tag == 5)
    {
        
        if (range.location >= 12)
            return NO;}
    if (textField.tag == 6)
    {
        if (range.location>=12)
            return NO;}
    return YES;
}





-(void)startTime{
    
    if ([phoneTextField.text length]<1)
    {
        [self showAlertMessage:@"请输入手机号码"];
    }else{
        if ([phoneTextField.text length]!=11)
        {
            [self showAlertMessage:@"手机位数有误"];
        }else{
            
            __block int timeout=60; //倒计时时间
            dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
            dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
            dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
            dispatch_source_set_event_handler(_timer, ^{
                if(timeout<=0){ //倒计时结束，关闭
                    dispatch_source_cancel(_timer);
                    dispatch_async(dispatch_get_main_queue(), ^{
                        //设置界面的按钮显示 根据自己需求设置
                        
                        
                        
                        
                        [ToObtain setTitle:@"获取" forState:UIControlStateNormal];
                        ToObtain.userInteractionEnabled = YES;
                    });
                }else{
                    //            int minutes = timeout / 60;
                    int seconds = timeout % 60;
                    NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds];
                    dispatch_async(dispatch_get_main_queue(), ^{
                        //设置界面的按钮显示 根据自己需求设置
                        //                NSLog(@"____%@",strTime);
                        if (strTime.intValue==59) {
                            NSLog(@"____%@",strTime);
                            
                            
                            
                            NSMutableDictionary *params = [NSMutableDictionary new];
                            [params setValue:phoneTextField.text forKey:@"mobile"];
                            [params setValue:@"R" forKey:@"msgType"];
                            
                            
                            [HttpRequest requestData:@"System/SendMsg" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                                if (isSuccess) {
                                    NSLog(@"====%@",severDataDict.dataDict);
                                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                                        [Global hideProgressHUDInternal:self.view];
                                        NSString*ResultString=[severDataDict.dataDict objectForKey:@"ResultString"];
                                        [self showAlertMessage:ResultString];
                                        
                                    }else{
                                        [Global hideProgressHUDInternal:self.view];
                                        
                                        
                                        
                                        
                                    }
                                }
                                else
                                {
                                    [Global hideProgressHUDInternal:self.view];
                                    
                                    [Global showTextHudSub:severDataDict.resultStr view:self.view];
                                    
                                    
                                    
                                }
                                
                            }];
                        }
                        
                        if (![strTime isEqualToString:@"00"]) {
                            [ToObtain setTitle:[NSString stringWithFormat:@"%@秒重获",strTime] forState:UIControlStateNormal];
                            
                        }
                        ToObtain.userInteractionEnabled = NO;
                        
                    });
                    timeout--;
                    
                }
            });
            dispatch_resume(_timer);
            
        }
        
    }
    
}


-(void)regist:(UIButton*)sender{
    
    
    if ([phoneTextField.text length]<1)
    {
        [self showAlertMessage:@"请输入手机号码"];
        
    }else if ([VerificationCode.text length]<1)
    {
        [self showAlertMessage:@"请输入验证码"];
    }
 
    else{
        
        [Global showIndeterminateHud:@"注册中，请稍后。。。" delay:20 view:self.view];
        
        NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
        NSString* tokenId = [user1 objectForKey:@"tokenId"];
        NSMutableDictionary *params = [NSMutableDictionary new];
        [params setValue:tokenId forKey:@"tokenId"];
        [params setValue:userNameTextField.text forKey:@"userName"];
        [params setValue:phoneTextField.text forKey:@"bossPhone"];
        [params setValue:VerificationCode.text forKey:@"bossPhoneRandNum"];
        [params setValue:self.code forKey:@"userType"];
        
        [HttpRequest requestData:@"System/SubmitUserAuthInfo" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                NSLog(@"====%@",severDataDict.dataDict);
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    NSString*UserName=phoneTextField.text;
                    NSString*Password=PasswordTextField.text;
                    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
                    [user setObject:UserName forKey:@"mobile"];
                    [user setObject:Password forKey:@"loginWord"];
                    
                    [user synchronize];
                    [self.navigationController popViewControllerAnimated:YES];
                    
                    
                    
                    
                }else{
                    [Global hideProgressHUDInternal:self.view];
                    
                    
                    [self showAlertMessage:[severDataDict.dataDict objectForKey:@"ResultString"]];
                    
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                
                [Global showTextHudSub:severDataDict.resultStr view:self.view];
                
                
                
            }
            
        }];
        
    }}


- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定哦 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}


- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:2.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)OnTapDone{
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    mainScroll .frame =CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
    [payPasswordTextField resignFirstResponder];
    [phoneTextField resignFirstResponder];
    [userNameTextField resignFirstResponder];
    [PasswordTextField resignFirstResponder];
    [VerificationCode resignFirstResponder];
    
    
    if (VerificationCode.text.length>1) {
        [registdd removeFromSuperview];
        
        registdd = [[UIButton alloc] initWithFrame:CGRectMake(15,540/2, ScreenWidth-30, anniuHeigth)];
        [registdd setTitle:@"立即认证" forState:UIControlStateNormal];
        [registdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        registdd.backgroundColor=luseColor;
        [registdd.layer setCornerRadius:3.0]; //设置矩圆角半径
        [registdd.layer setBorderWidth:0.3];   //边框宽度
        CGColorSpaceRef tureBTnSpace = CGColorSpaceCreateDeviceRGB();
        CGColorRef tureBTncolorref = CGColorCreate(tureBTnSpace,(CGFloat[]){23/255.0,148/255.0, 153/255.0, 1.0});
        [registdd.layer setBorderColor:tureBTncolorref];//边框颜色
        [registdd addTarget:self action:@selector(regist:) forControlEvents:UIControlEventTouchUpInside];
        [mainScroll addSubview:registdd];
        
        
    }

}
//回收键盘
-(void)closeKeyBoad

{
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    mainScroll .frame =CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];[payPasswordTextField resignFirstResponder];
    [phoneTextField resignFirstResponder];
    [userNameTextField resignFirstResponder];
    [PasswordTextField resignFirstResponder];
    [VerificationCode resignFirstResponder];
}


@end
